package com.vframework.rest.common;

import java.util.Map;

/***************************************************************
 * Name:        RestResponse.java
 * Create At:   2018年4月11日
 * Module:      
 * Description: [功能描述]
 * @author      shanzhitong
 * ------------------------------------------------------------
 * 修改历史
 * 序号         日期                       修改人               修改原因
 * 1    2018年4月11日      shanzhitong    
 * 2
***************************************************************/
public class RestResponse {
	public static final String SUCCESS_CODE = "0000";
	public static final String SUCCESS_MESSAGE = "success";
	private String code = SUCCESS_CODE;
	private String message =  SUCCESS_MESSAGE;
	private Map<?, ?> data;
	public RestResponse() {
	}
	public RestResponse(Status s) {
		this.code = s.code_;
		this.message = s.msg;
	}
	public RestResponse(String code, String msg, Map<?, ?> data) {
		this.code= code;
		this.message = msg;
		this.data = data;
	}
	public RestResponse(Map<?, ?> data) {
		this.data = data;
	}
	public RestResponse(String code, String msg) {
		this.code= code;
		this.message = msg;
	}
	
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	@SuppressWarnings("unchecked")
	public Map<String, Object> getData() {
		return (Map<String, Object>) data;
	}
	public void setData(Map<String, Object> data) {
		this.data = data;
	}
	public String toString(){
		return this.code+","+this.message;
	}
	public enum Status {
		SUCCESS("0000","成功"),
		ERROR("1000","系统出错"),
		UNAUTHORIZED("0001","未认证"),
	    UNLOGIN("0002","未登录"),
	    NOORG("0003", "未定义orgId");
        private String code_;
        private String msg;
        private Status(String code_, String msg) {
            this.code_ = code_;
            this.msg = msg;
        }
    }
}
